package co.yixiang.modules.shop.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import co.yixiang.modules.shop.entity.YxStoreProductRelation;
import co.yixiang.modules.shop.web.param.YxStoreProductRelationQueryParam;
import co.yixiang.modules.shop.web.vo.YxStoreProductRelationQueryVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.io.Serializable;
import java.util.List;

/**
 * <p>
 * 商品点赞和收藏表 Mapper 接口
 * </p>
 *
 * @author hupeng
 * @since 2019-10-23
 */
@Repository
public interface YxStoreProductRelationMapper extends BaseMapper<YxStoreProductRelation> {

    @Select("select B.id productId ,A.category,B.store_name as storeName, b.unit_name unitName," +
            "B.image,B.place,b.is_invested isInvested,b.invest_cost investCost,b.invest_price investPrice," +
            "B.sales_reference as salesReference ,B.lock_status lockStatus,B.lock_release_date_time lockReleaseDateTime," +
            "B.lock_time lockTime,B.locker,B.lock_type lockType,B.brand_name brandName,B.warehouse_stock as warehouseStock,B.store_pname as storePname" +

            " from yx_store_product_relation A left join yx_store_product B " +
            "on A.product_id = B.id where A.uid=#{uid} and A.type = #{type} and is_del =0  and is_invest_on =1")
    List<YxStoreProductRelationQueryVo> selectList(Page page,@Param("uid") int uid, @Param("type") String type);
    
    /**
     * 根据ID获取查询对象
     * @param id
     * @return
     */
    YxStoreProductRelationQueryVo getYxStoreProductRelationById(Serializable id);

    /**
     * 获取分页对象
     * @param page
     * @param yxStoreProductRelationQueryParam
     * @return
     */
    IPage<YxStoreProductRelationQueryVo> getYxStoreProductRelationPageList(@Param("page") Page page,
                                                                           @Param("param") YxStoreProductRelationQueryParam yxStoreProductRelationQueryParam);

}
